package com.lagou.service.impl;


import com.lagou.base.StatusCode;
import com.lagou.dao.CourseLessonDao;
import com.lagou.dao.impl.CourseLessonDaoImpl;
import com.lagou.pojo.Course_Lesson;
import com.lagou.service.CourseLessonService;
import com.lagou.utils.DateUtils;

import java.util.Date;

/**
 * @author cyt
 * @date 2020/8/29
 */
public class CourseLessonServiceImpl implements CourseLessonService {
    private CourseLessonDao courseLessonDao = new CourseLessonDaoImpl();


    @Override
    public String saveCourseLesson(Course_Lesson lesson) {

        //补全信息
        String datetime = DateUtils.getDateFormart();
        lesson.setCreate_time(datetime);
        lesson.setUpdate_time(datetime);

        return courseLessonDao.saveLesson(lesson) == 0 ? StatusCode.FAIL.toString() : StatusCode.SUCCESS.toString();
    }

    @Override
    public String updateCourseLesson(Course_Lesson lesson) {
        //补全信息
        lesson.setUpdate_time(DateUtils.getDateFormart());
        return courseLessonDao.updateLesson(lesson) == 0 ? StatusCode.FAIL.toString() : StatusCode.SUCCESS.toString();

    }
}
